﻿using System;
using System.Data;
using System.Configuration;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for URL
/// </summary>
namespace UI
{
    public class URL : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            // get the requested page name like article1.aspx
            string strUrl = System.IO.Path.GetFileName(context.Request.Url.AbsolutePath);

            if (strUrl.EndsWith("nyhed.aspx") == true)
            {
                string id = strUrl.Substring(0, 4);
                HttpContext.Current.Server.Transfer("~/Nyhed.aspx?id=" + id);
            }
            
            if (strUrl.EndsWith("spil.aspx") == true)
            {
                string id = strUrl.Substring(0, 5);
                HttpContext.Current.Server.Transfer("~/Spil.aspx?id=" + id);
            }

            if (strUrl.EndsWith("video.aspx") == true)
            {
                string id = strUrl.Substring(0, 5);
                HttpContext.Current.Server.Transfer("~/videoplayer.aspx?id=" + id);
            }

            else
            {
                string id = strUrl.Substring(0, 4);
                HttpContext.Current.Server.Transfer("~/Anmeldelse.aspx?id=" + id);
            }
        }

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    }
}